package jmine.tec.script.impl;

import java.util.ArrayList;
import java.util.List;

import jmine.tec.script.ScriptLogger;

/**
 * @author seiti
 * @created May 16, 2011
 */
public class ScriptLoggerImpl implements ScriptLogger {

    private boolean success = true;

    private List<String> logs = new ArrayList<String>();

    private StringBuilder tracer = new StringBuilder();

    /**
     * {@inheritDoc}
     */
    public boolean isSuccess() {
        return success;
    }

    /**
     * {@inheritDoc}
     */
    public void fail(String msg) {
        this.success = false;
        this.logs.add(msg);
    }

    /**
     * {@inheritDoc}
     */
    public void fail(String msg, Throwable t) {
        this.fail(msg);
        this.logs.add(t.getMessage());
    }

    /**
     * {@inheritDoc}
     */
    public void info(String msg) {
        this.logs.add(msg);
    }

    /**
     * {@inheritDoc}
     */
    public List<String> getLogs() {
        return this.logs;
    }

    /**
     * {@inheritDoc}
     */
    public void trace(String trace) {
        this.tracer.append(trace);
    }

    /**
     * {@inheritDoc}
     */
    public String getTraces() {
        return tracer.toString();
    }
}
